home *** CD-ROM | disk | FTP | other *** search
- ;/*
- F_Create.rexx EXE CrazyGauges
- QUIT
- ________________________________________________________________________
-
- $VER: CrazyGauges 1.0 (2003/02/10) by Olivier LAVIALE.
-
- This example illustrare how to write a subclass using a methods table
- instead of a dispatcher, and Dynamic IDs.
-
- */
-
- ///Header
- #include <stdlib.h>
-
- #include <intuition/intuition.h>
- #include <libraries/feelin.h>
-
- #include <proto/exec.h>
- #include <proto/dos.h>
- #include <proto/utility.h>
- #include <proto/feelin.h>
-
- struct FeelinBase *FeelinBase;
- #define UtilityBase FeelinBase -> Utility
-
- struct LocalObjectData
- {
- BYTE Mode;
- BYTE Way;
- };
-
- #define CrazyObject F_NewObj(Class -> Name
- #define Crazy(h,min,max,val,mode) CrazyObject, \
- FA_Horizontal, h, \
- "FA_Numeric_Min", min, \
- "FA_Numeric_Max", max, \
- "FA_Numeric_Value", val, \
- F_IDA(FA_CrazyGauge_Mode), mode, \
- End
-
- enum { // Resolved Dynamic IDs
-
- FA_Numeric_Value,
- FA_Numeric_Min,
- FA_Numeric_Max,
- FA_Gauge_Simple
-
- };
-
- enum { // Class's attributes
-
- FA_CrazyGauge_Mode
-
- };
-
- enum { // Special values for FA_CrazyGauge_Mode
-
- FV_CrazyGauge_More,
- FV_CrazyGauge_Less,
- FV_CrazyGauge_TwoWays,
- FV_CrazyGauge_Crazy
-
- };
- //+
-
- ///Crazy_New
- F_METHODM(ULONG,Crazy_New,TagItem)
- {
- struct LocalObjectData *LOD = F_LOD(Class,Obj);
-
- LOD -> Way = TRUE;
- LOD -> Mode = F_DynamicGTD(F_IDA(FA_CrazyGauge_Mode),FV_CrazyGauge_More,Msg);
-
- return F_SUPERDO();
- }
- //+
- ///Crazy_Setup
- F_METHOD(ULONG,Crazy_Setup)
- {
- if (F_SUPERDO())
- {
- F_Do(Obj,FM_ModifyHandler,IDCMP_INTUITICKS,0);
-
- return TRUE;
- }
- return FALSE;
- }
- //+
- ///Crazy_Cleanup
- F_METHOD(void,Crazy_Cleanup)
- {
- F_Do(Obj,FM_ModifyHandler,0,IDCMP_INTUITICKS);
-
- F_SUPERDO();
- }
- //+
- ///Crazy_HandleEvent
- F_METHODM(ULONG,Crazy_HandleEvent,FS_HandleEvent)
- {
- struct LocalObjectData *LOD = F_LOD(Class,Obj);
-
- if (Msg -> FEv -> Class == IDCMP_INTUITICKS)
- {
- LONG val,max,min;
-
- F_Do(Obj,FM_Get,
- F_IDR(FA_Numeric_Value), &val,
- F_IDR(FA_Numeric_Max), &max,
- F_IDR(FA_Numeric_Min), &min, TAG_DONE);
-
- switch (LOD -> Mode)
- {
- case FV_CrazyGauge_More:
- {
- F_Set(Obj,F_IDR(FA_Numeric_Value),(val == max) ? min : val + 1);
- }
- break;
-
- case FV_CrazyGauge_Less:
- {
- F_Set(Obj,F_IDR(FA_Numeric_Value),(val == min) ? max : val - 1);
- }
- break;
-
- case FV_CrazyGauge_TwoWays:
- {
- if (LOD -> Way)
- {
- if (val == max) LOD -> Way = FALSE;
- else F_Set(Obj,F_IDR(FA_Numeric_Value),val + 1);
- }
- else
- {
- if (val == min) LOD -> Way = TRUE;
- else F_Set(Obj,F_IDR(FA_Numeric_Value),val - 1);
- }
- }
- break;
-
- case FV_CrazyGauge_Crazy:
- {
- F_Set(Obj,F_IDR(FA_Numeric_Value),rand() % max);
- }
- break;
- }
- }
- return 0;
- }
- //+
-
- ///Main
- void main(void)
- {
- /* Attributes of my class */
-
- static struct FeelinDynamicEntry Attributes[] =
- {
- "Mode",0, NULL
- };
-
- /* Dynamic IDs from my superclasses (don't need auto resolve) */
-
- static struct FeelinDynamicEntry Resolve[] =
- {
- "FA_Numeric_Value", 0,
- "FA_Numeric_Min", 0,
- "FA_Numeric_Max", 0,
- "FA_Gauge_Simple", 0, NULL
- };
-
- /* Methods handled by my class */
-
- static struct TagItem MTable[] =
- {
- (ULONG) Crazy_New, NULL, FM_New,
- (ULONG) Crazy_Setup, NULL, FM_Setup,
- (ULONG) Crazy_Cleanup, NULL, FM_Cleanup,
- (ULONG) Crazy_HandleEvent, NULL, FM_HandleEvent,
- NULL
- };
-
- struct FeelinClass *Class;
- FObject app,win, g,b;
-
- if (FeelinBase = (APTR) OpenLibrary("feelin.library",FV_VERSION))
- {
- if (Class = F_CreateClass(FA_Class_LODSize, sizeof (struct LocalObjectData),
- FA_Class_Super, FC_Gauge,
- FA_Class_Attributes, Attributes,
- FA_Class_MethodsTable, MTable,
- FA_Class_ResolveTable, Resolve,
- TAG_DONE))
- {
- app = AppObject,
- FA_Application_Title, "demo_CrazyGauges",
- FA_Application_Version, "$VER: CrazyGauges 1.00 (2003/02/10)",
- FA_Application_Copyright, "© 2000-2003 - Olivier LAVIALE",
- FA_Application_Author, "Olivier LAVIALE <HaploLaMain@aol.com>",
- FA_Application_Description, "Show gauges & custom class",
- FA_Application_Base, "CRAZYGAUGES",
-
- FA_ColorScheme, "c:FFDCA0,c:AA7864,,c:2A1E19",
-
- Child, win = WindowObject,
- FA_ID, MAKE_ID('M','A','I','N'),
- FA_Window_Title, "Feelin : Gauges",
- FA_Window_Open, TRUE, /* Windows are only opened when the Client is launched (if not in sleep mode) */
- FA_Back, FI_Fill,
-
- Child, VGroup,
- Child, g = HGroup,
- Child, VGroup,
- Child, Gauge(TRUE,0,100,25),
- Child, Gauge(TRUE,0,100,50),
- Child, Gauge(TRUE,0,100,75),
- Child, Gauge(TRUE,0,100,100),
- Child, Crazy(TRUE,0,100,0,FV_CrazyGauge_Crazy),
- End,
-
- Child, BalanceObject, FA_ID,MAKE_ID('B','L','N','C'), "FA_Balance_QuickDraw", TRUE, End,
-
- Child, VGroup, FA_SetMax,FV_SetMaxH,
- Child, Crazy(TRUE,0,100, 0,FV_CrazyGauge_TwoWays),
- Child, Crazy(TRUE,0,100,100,FV_CrazyGauge_TwoWays),
- Child, Crazy(TRUE,0,100, 0,FV_CrazyGauge_TwoWays),
- Child, Crazy(TRUE,0,100,100,FV_CrazyGauge_TwoWays),
- End,
- End,
-
- Child, b = TextObject,
- FA_InputMode, FV_InputMode_Toggle,
- FA_SetMax, TRUE,
- FA_Inner_Left, 6,
- FA_Inner_Right, 6,
- FA_Inner_Top, 3,
- FA_Inner_Bottom, 3,
- FA_Frame, "0:21.0,0:00.0",
- FA_Back, "0:3,0:7",
- FA_Text, "Toggle Gauges Look",
- FA_Text_PreParse, "<pens style=glow>",
- FA_Text_AltPreParse, "<pens text=shine>",
- FA_Text_VCenter, TRUE,
- End,
- End,
-
- FA_Window_ActiveObject, b, /* This is safe here */
- End,
- End;
-
- if (app)
- {
- F_Do(b,FM_Notify,FA_Selected,FV_Notify_Always,g,FM_Set,4,F_IDR(FA_Gauge_Simple),FV_Notify_Value,FA_Group_Forward,TRUE);
- F_Do(win,FM_Notify,FA_Window_CloseRequest,TRUE,app,FM_Application_Shutdown,0);
-
- F_Do(app,FM_Application_Run);
-
- F_DisposeObj(app);
- }
- else Printf("Unable to create application\n");
-
- F_DeleteClass(Class);
- }
- else Printf("Unable to create custom class\n");
-
- CloseLibrary(FeelinBase);
- }
- else Printf("Unable to open feelin.library %ld\n",FV_VERSION);
- }
- //+
-